/**
 * creater:zhiqiang.zhao@dhc.com.cn
 * create time:12/27/2016, 2:16:48 PM
 * describe:测试
 */
APP.controller('MenuController', ['$scope', 'MenuService',
  function ($scope, MenuService) {

    /***变量声明***/
    $scope.username = undefined;
    $scope.password = undefined;

    /**
     * 初始化函数
     */
    $scope.init = function () {
      console.log('菜单页面初始化');

    };

    /**
     * 登录方法
     */
    $scope.login = function () {
      MenuService.doLogin($scope.username, $scope.password)
        .then(function (response) {
          console.log('成功回调方法', response)
        }, function (response) {
          console.log('失败回调方法', response)
        })
    };


    /*
     $scope.init();//如果页面缓存则用此方法初始化
     */
    $scope.$on('$ionicView.beforeEnter', function () {
      $scope.init();
    });
  }
]);

/**
 * creater:zhiqiang.zhao@dhc.com.cn
 * create time:12/27/2016, 2:16:48 PM
 * describe:测试
 */
APP.service('MenuService', ['$http', 'UrlService', function ($http, UrlService) {
  /**
   * 登录方法
   * @param username  登录用户名
   * @param password  登录密码
   */
  this.doLogin = function (username, password) {
    var param = {
      username: username,
      password: password
    };
    return $http.post(UrlService.getUrl('LOGIN'), param);
  }

}]);
